/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.j4sc;

import org.apache.commons.lang.StringUtils;

import com.googlecode.j4sc.submission.Submission;

/**
 * The UserCredentials class is used to store the user name and password of your
 * SpinVox Create account. It is used in order to construct a {@link Submission}
 * for submitting to the service.
 * 
 * @author Raj Patel, Dariusz Lorenc
 */
public class UserCredentials {

	private final String username;
	private final String password;

	/**
	 * Construct an UserCredentials 
	 * 
	 * @param username the username for your SpinVox Create account, cannot be null or empty
	 * @param password the password for your SpinVox Create account, cannot be null or empty
	 * @throws IllegalArgumentException 
	 * 		thrown if invalid values are provided
	 */
	public UserCredentials(String username, String password) throws IllegalArgumentException {
		this.username = enforceNotEmpty(username, "Username");
		this.password = enforceNotEmpty(password, "Password");
	}

	private String enforceNotEmpty(String value, String fieldName) {
		if(StringUtils.isBlank(value)) {
			throw new IllegalArgumentException(
					String.format("%s cannot be null or empty", fieldName));
		}
		return value;
	}

	/**
	 * Your account username
	 * 
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}
	
	/**
	 * Your account password
	 * 
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
}
